
<#include "/common/head.html"/>
    
    <table id="dg"></table>
    <div id="tb" style="padding:2px 5px;">
        <div class="wrap_search">
		        		
			            	<span class="search_item">
				            	<span class="item_text">活动主题: </span>
				            	<span class="item_obj">
				            		<input class="easyui-textbox" type="text" name="title" id="title" value=""/>
				            	</span>    
				            </span>
		        		
			        		<span class="search_item search_between">
				                <span class="item_text">开始时间: </span>
				                <span class="item_obj">
				                    <input class="easyui-datebox" name="_start_starttime" id="_start_starttime" value=""/> ～ <input class="easyui-datebox" name="_end_starttime" id="_end_starttime" value=""/>
				                </span>
				            </span>
		        		
			        		<span class="search_item search_between">
				                <span class="item_text">结束时间: </span>
				                <span class="item_obj">
				                    <input class="easyui-datebox" name="_start_endtime" id="_start_endtime" value=""/> ～ <input class="easyui-datebox" name="_end_endtime" id="_end_endtime" value=""/>
				                </span>
				            </span>
        </div>
        <div class="dg_btns_wrap">
            <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">增加</a>
            <a href="javascript:void(0)" class="easyui-linkbutton updateBtn" iconCls="glyphicon-pencil" plain="true" onclick="update()">编辑</a>
            <a href="javascript:void(0)" class="easyui-linkbutton delBtn" iconCls="glyphicon-remove" plain="true" onclick="del()">删除</a>
            <a href="javascript:void(0)" class="easyui-linkbutton detailBtn" iconCls="glyphicon-map-marker" plain="true" onclick="detail()">详情</a>
            <a href="javascript:void(0)" class="easyui-linkbutton exportBtn" iconCls="glyphicon-export" plain="true" onclick="exportCsv()">导出</a>
            <div id="searchBtnWrap" style="float:right; padding-right:40px;">
                <a href="javascript:void(0)" class="easyui-linkbutton color1" iconCls="glyphicon-search" onclick="zcurdSearch(this)">搜索</a>
                <a href="javascript:void(0)" class="easyui-linkbutton color2" iconCls="glyphicon-repeat" onclick="flushPage()">重置</a>
            </div>
        </div>
    </div>
    

<script type="text/javascript">
var datagrid = $("#dg");

var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
        rownumbers:true,
    	url:'listData',
    	method:'post',
    	toolbar:'#tb',
    	pageSize: 20,
    	pagination:true,
    	multiSort:true,
		sortName: getInitParam().sort,
    	sortOrder: getInitParam().order,
        queryParams: getInitParam(),
        
        columns: [[
		         {field:'id', checkbox:true}
	           	 ,{field:'title', title: '活动主题', width:120, sortable: true }
	           	 ,{field:'info', title: '活动简介', width:120, sortable: true }
	           	 ,{field:'starttime', title: '开始时间', width:120, sortable: true }
	           	 ,{field:'endtime', title: '结束时间', width:120, sortable: true }
	           	 ,{field:'type', title: '类型', width:120, sortable: true }
	           ]],
	           loadFilter: function(data) {
	        	   if(data.result && data.result == 'fail') {	//失败时，错误消息提示
	        		   showWarnMsg(data.msg);
	        		   return {};
	        	   }else {
	        		   return data;
	        	   }
	           }           
	};
$(function() {
	handleAuthDataRule();
	datagrid.datagrid(dgOptions);
});

function zcurdSearch() {
	var param = zcurdGetParam();
	datagrid.datagrid("load", {
		queryParams: param
	})
}

function zcurdGetParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param[$(item).attr("name")] = $(item).val();	
		}
	});
    param["status"] = 1;
	return param;
}

function getInitParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param["queryParams[" + $(item).attr("name") + "]"] = $(item).val();	
		}
	});
    param["queryParams[status]"] = 1;
	if("") {
		param.sort = "";
		param.order = "asc";
	}
	return param;
}

var initPara = zcurdGetParam();

function detail() {
	var rowsSel = datagrid.datagrid("getSelections");
	if(rowsSel.length != 1) {
		showWarnMsg("请选择需要查看的一条数据！");
		return;
	}
	var id = rowsSel[0].id;
	top.openWindow("历史活动-详情", getCurrUrl("detailPage") + "?id=" + id, {size: '600x600'});
}

function exportCsv() {
	var option = datagrid.datagrid("options");
	var param = option.queryParams;
	param.sortName = option.sortName;
	param.sortOrder = option.sortOrder;
	window.location.href = "exportCsv?" + $.param(param);
}

//按钮事件

/**
 * 打开子页
 */
var _openSubPageFlag = false;
function _openSubPage(pageUrl) {
	if(!_openSubPageFlag) {
		$("#subLayout").layout("expand", "east");
		setTimeout(function() {
			$("#subIframe").attr("src", pageUrl);
		}, 600);
		_openSubPageFlag = true;
	}else {
		$("#subIframe").attr("src", pageUrl);
	}
}

//扩展js
</script>

<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>
